package de.arndt_plc.wakeonmagic;

import android.app.Activity;
import android.appwidget.AppWidgetManager;
import android.content.Intent;
import android.os.Bundle;


/**
 * The configuration screen for the {@link WakeOnMagicAppWidgetProvider WakeOnMagicAppWidgetProvider} AppWidget.
 */
public class WakeOnMagicAppWidgetConfigureActivity extends Activity {

    public static final String TAG = WakeOnMagicAppWidgetConfigureActivity.class.getSimpleName();

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        // Set the result to CANCELED.  This will cause the widget host to cancel
        // out of the widget placement if the user presses the back button.
        setResult(RESULT_CANCELED);

        // Find the widget id from the intent.
        int appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
        Intent intent = getIntent();
        Bundle extras = intent.getExtras();
        if (extras != null) {
            appWidgetId = extras.getInt(
                    AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        }

        // If this activity was started with an intent without an app widget ID, finish with an error.
        if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
            finish();
            return;
        }

        // append fragment
        setContentView(R.layout.wake_on_magic_app_widget_configure_activity);
        WakeOnMagicAppWidgetConfigureFragment configFragment = WakeOnMagicAppWidgetConfigureFragment.newInstance(appWidgetId, false);
        getFragmentManager().beginTransaction().replace(R.id.container, configFragment).commit();

    }
}



